package com.tac.controller.mes;

import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.pojo.mes.QualityTraceability;
import com.tac.service.mes.QualityTraceabilityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@CrossOrigin
@Api(tags = "制造执行MES--质量管理--质量追溯")
@RequestMapping("/qualityTraceabilityService")
@RestController
public class QualityTraceabilityController {


    @Autowired
    private QualityTraceabilityService qualityTraceabilityService;

    //质量追溯查看
    @GetMapping("/getList")
    @ApiOperation("质量追溯查看")
    public Result<PageInfo<QualityTraceability>> getList(Integer pageNum, Integer pageSize, String serialNumber, String completionNumber, String planNumber, String jobName, String productName
            , String inspectionBatch, @DateTimeFormat(pattern = "yyyy-MM-dd")Date productionDateStart, @DateTimeFormat(pattern = "yyyy-MM-dd")Date productionDateEnd, String inspectionItem, String inspectionResult, String inspector,
                                                         @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date inspectionTimeStart,  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date inspectionTimeEnd){
        return qualityTraceabilityService.getList(pageNum, pageSize, serialNumber, completionNumber, planNumber, jobName, productName, inspectionBatch, productionDateStart, productionDateEnd, inspectionItem, inspectionResult, inspector,  inspectionTimeStart, inspectionTimeEnd);

    }
    //质量追溯删除
    @DeleteMapping("/remove")
    @ApiOperation("质量追溯删除")
    public Result remove(@RequestBody List<Integer> ids){
       return qualityTraceabilityService.remove(ids);
    }
    //质量追溯修改
    @PutMapping("/update")
    @ApiOperation("质量追溯修改")
    public Result update(@RequestBody  QualityTraceability qualityTraceability){
       return qualityTraceabilityService.update(qualityTraceability);
    }
    //质量追溯添加
    @PostMapping("/save")
    @ApiOperation("质量追溯添加")
    public Result save(@RequestBody  QualityTraceability qualityTraceability){
       return qualityTraceabilityService.save(qualityTraceability);
    }
}
